package com.itcodai.service.message;

import com.itcodai.config.message.ActiveMqConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

/**
 * 队列消息消费者
 * @author c-fanqj
 * @date 2023/4/18
 * @apiNote
 */
@Service
public class QueueConsumerService {

    private final Logger logger =
            LoggerFactory.getLogger(this.getClass());

    /**
     * 接受点对点消息
     * @param msg
     */
    // 使用 @JmsListener 注解来指定要监听的目的地
    @JmsListener(destination = ActiveMqConfig.QUEUE_NAME)
    public void receiveQueueMsg(String msg) {
        logger.info("Queue收到的消息为：{}", msg);
        // Queue收到的消息为：Queue:hello activemq! -jiejie5
        // Queue收到的消息为：Queue:hello activemq! -jiejie555
    }

}
